/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/


#include "CorrelationParent.h"


/*
  Constructor for all derived classes
  */
CorrelationParent::CorrelationParent() {

    /* ----- Initialize Local Variables ------------------------------------------------------------------------------ */

    // Image arrays
    colorSpace = 0;
    colorSpacePrev = 0;


    /* ----- Initialize Global Variables ----------------------------------------------------------------------------- */

    // Object re-initialization
    persistFileString = "/home/administrator/Documents/correlate/persistentValues.dat";

    // Runtime logic
    enable_debug = 0;  // Call function with --enable-debug to output spiffy stuff during analysis
    enable_step = false;  // Pause after outputting image every time step
    image_sequence = -1;  // Flag -is=### runs with pre-stored image sequence number ###

    // Image data
    h = -1;
    w = -1;
    ROI.x = 0;
    ROI.y = 0;
    ROI.width = 100;
    ROI.height = 100;

    // Image filter logic variables
    H_lower = 85;
    H_upper = 170;
    S_lower = 85;
    S_upper = 170;
    V_lower = 85;
    V_upper = 170;

    R_lower = 85;
    R_upper = 170;
    G_lower = 85;
    G_upper = 170;
    B_lower = 85;
    B_upper = 170;

    // Blob analysis logic variables
    num_blobs = 0;
    found = 0;
    min_blob_area = 0;
    max_blob_area = 10000;

    // Post process logic variables
    blob_dist_thresh = 50;  // Static migration distance threshold

    // Position field logic variables
    area_thresh = 25;
    num_dots = 0;
    migration_dist_thresh = 50;

    // Position field data

    // Variables used for generateGridMap()
//    min_direction_angle = 80*M_PI/180;  // Units are radians
//    max_direction_angle = 100*M_PI/180;
    min_direction_angle = 20*M_PI/180;  // Units are radians
    max_direction_angle = 160*M_PI/180;
    max_neighbor_dist = 10000;

    //tmp
    t = 0;
    dotProbabilityThresh = 0.9;

    for(int b = 0; b < max_num_blobs; ++b) {
        epsxx[b] = 0;
        epsxy[b] = 0;
        epsyx[b] = 0;
        epsyy[b] = 0;
        positionField_ref[0][b] = -1;
        positionField_ref[1][b] = -1;
        positionField[0][b] = -1;
        positionField[1][b] = -1;
    }

}
